<?php
	header('Access-Control-Allow-Origin: *');
    $clent_id = "703832578";
    $client_secret = "9e05df8606ff915fb3109e5e6bdfcd58";
    $redirectUri = "http://wap.soolife.cn/view/account/login_sina.html";
  
   $code = $_REQUEST['code'];

   // 获取acess_token
   // https://api.weibo.com/oauth2/access_token?client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&grant_type=authorization_code&redirect_uri=YOUR_REGISTERED_REDIRECT_URI&code=CODE
   $token_url = "https://api.weibo.com/oauth2/access_token?client_id=" . $clent_id ."&client_secret=" . $client_secret . "&grant_type=authorization_code&redirect_uri=" . $redirectUri . "&code=" . $code;

   $opts = array('http' =>
                        array(
                            'method'  => 'POST',
                            'header'  => 'Content-type: application/x-www-form-urlencoded'
                        )
          );

  $context = stream_context_create($opts);
  $response = file_get_contents($token_url, false, $context);
  $res = json_decode($response, TRUE);
  // 获取用户信息
  $getuserURI = "https://api.weibo.com/2/users/show.json?access_token=" . $res['access_token'] . "&uid=" .  $res['uid'];

  $response = file_get_contents($getuserURI);
 	
  echo ( $response  );
  
